package io.sdph.controller;

import io.sdph.userprofile.ISessionManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


/**
 * Servlet odpowiedzialny za mozliwosc zamowienia produktow w panelu klienta (client.jsp)
 *
 * @author MODUL FRONTU (WWW)
 */
@Controller
@RequestMapping("/orderProducts")
public class ClientOrderProducts {
       
        private static final String PRODUCT_NAME = "products";
        private static final String SALES_REPRESENTATIVE = "salesRep";
        private static final String ANOTHER = "all";
       
        private static final String PAGE_VIEW = "client";

        /** Komponent pomocniczy do zarz�dzania sesj� u�ytkownika. */
        @Autowired
        ISessionManager sessionManager;
       
        //HttpServletRequest arg0, HttpServletResponse arg1
        @RequestMapping(method=RequestMethod.GET)
        public ModelAndView showPage() throws Exception {
               
                ModelAndView model = new ModelAndView(PAGE_VIEW);
                model.addObject("pageName", "products");
                return model;
        }
       
        @RequestMapping(method=RequestMethod.POST)
        public ModelAndView orderProducts(
                        @RequestParam(PRODUCT_NAME) final String productName,
                        @RequestParam(SALES_REPRESENTATIVE) final String salesRepresentative                     
        				) {
               
                ModelAndView model = new ModelAndView(PAGE_VIEW);
                              
                model.addObject("pageName", "products");
                return model;
        }
       
}
